package cate.common.table.farm.forbidden.sheet;

import cate.common.table.ESheet;
import cate.common.table.farm.forbidden.row.ForbiddenMonsterRow;
import com.fasterxml.jackson.annotation.JsonIgnore;
import easy.java.dev.note.NoteField;

import java.beans.Transient;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

public class ForbiddenMonsterSheet extends ESheet<ForbiddenMonsterRow> {
    @NoteField(value = "分组怪物", detail = "<分组，怪物配置列表>")
    public Map<Integer, List<String>> map = new HashMap<>();

    @Override
    public String getSheetName() {
        return "关卡怪物分组";
    }

    @Override
    protected void onRowCreated(ForbiddenMonsterRow row) {
        super.onRowCreated(row);
        List<String> list = map.get(row.id);
        if (list == null) {
            list = new ArrayList<String>();
            map.put(row.group, list);
        }
        list.add(row.monsterStr);
    }

    @JsonIgnore
    @Transient
    public List<ForbiddenMonsterRow> getListByBossGroup(int bossPlanId, int monsterPlanGroup) {
        return list.stream().filter(row -> row.group == monsterPlanGroup && row.bossId == bossPlanId).collect(Collectors.toList());
    }
}
